import 'codemirror/lib/codemirror.css';
import 'codemirror/theme/darcula.css';
import 'codemirror/theme/dracula.css';
import CodeMirror from 'codemirror'
import React from 'react';

class CodeEdit extends React.Component {
  componentDidMount() {
    let myCodeMirror = new CodeMirror(this.refs.codeBox,{
      theme: 'dracula',
      mode: 'javascript',
      value: "function myScript(){return 100;}\n",
      lineNumbers: true
    });
    myCodeMirror.on("change", function (e) {
      console.log(myCodeMirror.getValue());
      let msg = {};
      // msg.to = 'ybf';
      // msg.msg = myCodeMirror.getValue();
      // ws.send(JSON.stringify(msg));
    });
  }
  render() {
    return (
      <div ref="codeBox"></div>
    )
  }
}

export default CodeEdit